import time

def bubble_sort(nums):
    n = len(nums) - 1

    for i in range(n):
        w = False
        for j in range(n - i):
            if nums[j] > nums[j + 1]:
                nums[j], nums[j + 1] = nums[j + 1], nums[j]
                w = True
        if not w:
            break

def read_to_list(filename):
    file = open(filename)
    data = file.readlines()
    return [int(x) for x in data ]

filenames = ["m1_sorted.txt", "m2_reverse.txt", "m3_shuffle.txt"]

for filename in filenames:
   m = read_to_list(filename)
   t_start= time.time()
   bubble_sort(m)
   t_finish = time.time()
   print(filename.split('.')[0], round((t_finish-t_start)* 1000), "milliseconds")
